package com.xinzhi.controller;

import com.xinzhi.anno.CheckRole;
import com.xinzhi.domain.Applicant;
import com.xinzhi.service.ApplicantService;
import com.xinzhi.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import java.util.List;

@CrossOrigin
@Controller
@ResponseBody
@CheckRole(role = {"admin"})
@RequestMapping("/Applicant")
public class ApplicantController {
    @Autowired
    ApplicantService applicantService;
    @RequestMapping("/findAll")
    @ResponseBody
    public List<Applicant> findAll(){
        //查询团长全部的信息
        return applicantService.selectList();
    }

    @RequestMapping("/update")
    @ResponseBody
    public Result update(Applicant applicant){
        //修改团长信息
        return applicantService.updateApplicant(applicant);


    }

    @RequestMapping("/insert")
    @ResponseBody
    public Result insert(Applicant applicant){
        //添加团长信息
        return applicantService.insert(applicant);
    }
    @RequestMapping("/login")
    @ResponseBody
    public Result login(Applicant applicant){
        //团长进行登录
        return applicantService.login(applicant);
    }
    @RequestMapping("/updateremove")
    @ResponseBody
    public Result updateremove(Integer applicantId,Integer remove){
        //启用停用团长
        return applicantService.updateRemove(applicantId, remove);
    }
    @RequestMapping("/updatepass")
    @ResponseBody
    public Result updatepass(Integer applicantId,Integer pass){
        //通过不通过团长
        return applicantService.updatepass(applicantId,pass);
    }
    @RequestMapping("/selectpass")
    @ResponseBody
    public Result selectpass(Integer pass) {
        return applicantService.selectBypass(pass);

    }
    @ResponseBody
    @RequestMapping("/selectpass1")
    public Result selectpass1(Integer pass){
        return applicantService.selectBypass(pass);
    }
}
